<?php

namespace App\Observers\Game\Center;

use App\Caches\Game\AppResourceCache;
use App\Models\Game\Center\AppResource;

class AppResourceObserver
{
    /**
     * @param AppResource $data
     */
    public function created(AppResource $data)
    {
        AppResourceCache::set($data);
    }

    /**
     * @param AppResource $data
     */
    public function updated(AppResource $data)
    {
        // 删除原数据
        AppResourceCache::del($data->replicate()->fill($data->getOriginal()));
        AppResourceCache::set($data);
    }

    /**
     * @param AppResource $data
     */
    public function deleted(AppResource $data)
    {
        AppResourceCache::del($data);
    }
}
